<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>转让审核</title>
    #include("common/header.html")
    <link rel="stylesheet" href="/admin/css/table.css"/>
</head>

<body>
<div class="admin-main">

    <blockquote class="layui-elem-quote">
    </blockquote>
    <fieldset class="layui-elem-field">
        <legend>产品列表</legend>
        <div class="layui-field-box layui-form">
            <table class="layui-table admin-table">
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>电话</th>
                    <th>内容</th>
                    <th>积分</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody id="pager">
                </tbody>
            </table>
        </div>
    </fieldset>
    <!--<div class="admin-table-page">-->
    <div class="page-table-box" id="page" style=" width:1000px; margin:0 auto; margin-top:100px;"></div>
    <!--</div>-->
</div>
</body>

<script type="text/javascript">

    $(function () {
        pageList(1);
    });

    function pageList(pageNum) {

        $.ajax({
            url: "/admin/integral/",
            type: "post",
            dataType: "json",
            data: {"pageNum": pageNum, "pageSize": window.page.pageSize},
            success: function (r) {

                console.log(r);

                if (r.code == -1) {
                    return;
                }

                page(pageNum, r.data.total);

                $("#pager").html("");

                var str = "";

                $.each(r.data.list, function (n, value) {
                    str += '<tr>';
                    str += '<td>' + value.name + '</td>';
                    str += '<td>' + value.mobile + '</td>';
                    str += '<td>' + value.content + '</td>';
                    str += '<td>' + value.integral + '</td>';
                    str += '<td>';
                    str += '<a onclick="ok(' + value.id + ')" class="layui-btn layui-btn-normal layui-btn-mini">已发</a>';
                    str += '</td>';
                    str += '</tr>';
                });

                $("#pager").html(str);
            }
        });
    }


    var layer;
    layui.use('layer', function () {
        layer = layui.layer;
    });

    function ok(id) {
        //询问框
        layer.confirm('确定已发货?', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                url: "/admin/integral/ok",
                type: "put",
                data:{"id":id},
                dataType: "json",
                success: function (r) {
                    console.log(r);

                    if(r.code == -1){
                        layer.msg(r.msg);
                        return;
                    }
                    layer.msg('操作成功!',{time:1500}, function(){
                        //关闭后的操作
                        location.reload();
                    });
                }
            });
        });
    }

</script>

</html>